package com.example.intenttrial;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.View;
import android.widget.Button;

public class EmptyActivity extends Activity {

	Context context;
	Button button;
	static final String LOGTAG = "EmptyActivity";


	
	public static final String SERVICECMD = "com.android.music.musicservicecommand";
	public static final String CMDNAME = "command";
	public static final String CMDSTOP = "stop";
	public static final String CMDTOGGLEPAUSE = "togglepause";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		context = getApplicationContext();

		AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
		
		button = new Button(context);
		button.setText("button");

		setContentView(button);
	}

	@Override
	protected void onStart() {
		super.onStart();
		button.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(SERVICECMD);
//				if(mAudioManager.isMusicActive()) {
//				    i.putExtra(CMDNAME , CMDSTOP );
//				    sendBroadcast(i);
//				} else {
					i.putExtra(CMDNAME , CMDTOGGLEPAUSE );
				    sendBroadcast(i);
//				}
			}
		});
	}

	@Override
	protected void onResume() {
		super.onResume();
		System.out.println("onResume");
	}

	@Override
	protected void onPause() {
		super.onPause();
		System.out.println("onPause");
	}

}
